package com.ruoyi.web.controller.pc;


import com.ruoyi.business.domain.WmsDeliveryRecord;
import com.ruoyi.business.domain.WmsInWarehous;
import com.ruoyi.business.service.IWmsDeliveryRecordService;
import com.ruoyi.business.service.IWmsInWarehousService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 首页统计管理Controller
 *
 * @author ruoyi
 * @date 2023-12-24
 */
@RestController
@RequestMapping("/business/indexStat")
public class WmsIndexStatController extends BaseController {

    @Autowired
    private IWmsInWarehousService wmsInWarehousService;
    @Autowired
    private IWmsDeliveryRecordService wmsDeliveryRecordService;

    /**
     * @Description: 统计出库单数量
     * @author yunlong
     */
    @ApiOperation(value = "统计出库单数量")
    @GetMapping("statOutStoreNum")
    @CrossOrigin
    public AjaxResult statOutStoreNum() {
        WmsDeliveryRecord info = new WmsDeliveryRecord();
        info.setStatus("stat");
        info.setNowTime(DateUtils.dateTimeNow("yyyy-MM-dd"));
        List<WmsDeliveryRecord> list = wmsDeliveryRecordService.selectWmsDeliveryRecordList(info);
        return AjaxResult.success("",list.size());
    }

    /**
     * @Description: 统计入库单数量
     * @author yunlong
     */
    @ApiOperation(value = "统计入库单数量")
    @GetMapping("statInStoreNum")
    @CrossOrigin
    public AjaxResult statInStoreNum() {
        WmsInWarehous info = new WmsInWarehous();
        info.setStatus(4);
        info.setNowTime(DateUtils.dateTimeNow("yyyy-MM-dd"));
        List<WmsInWarehous> list = wmsInWarehousService.selectWmsInWarehousList(info);
        return AjaxResult.success("",list.size());
    }

    /**
     * @Description: 出入库统计
     * @author yunlong
     */
    @ApiOperation(value = "出入库统计")
    @GetMapping("statInOut")
    @CrossOrigin
    public AjaxResult statInOut(WmsInWarehous info) {
        Map<String,Object> result = new HashMap<>();
        List<Map<String, Object>> inList = wmsInWarehousService.statInOut(info);
        result.put("inList",inList);
        result.put("outList",wmsDeliveryRecordService.statInOut(info));
        return AjaxResult.success(result);
    }




}
